package com.lihepeng.leecode.array2;

/**
 *
 */
public class Solution303 {
    private int[]preSum;
    public Solution303(int[] nums) {
        preSum = new int[nums.length+1];
        preSum[0] = 0;
        for (int i=0;i<nums.length;i++) {
            preSum[i+1] = nums[i]+preSum[i];
        }
    }

    public int sumRange(int left, int right) {
        return preSum[right+1]-preSum[left];
    }
}
